//////////////////////////////////////
// Fast Container Library           //
// MIT License - Copyright (c) 2012 //
//////////////////////////////////////

#pragma once

#include "common.h"


FC_NAMESPACE_BEGIN


// base functions

template <class Argument, class Result>
struct unary_function
{
	typedef Argument	argument_type;
	typedef Result		result_type;
};


template <class Argument1, class Argument2, class Result>
struct binary_function
{
	typedef Argument1	first_argument_type;
	typedef Argument2	second_argument_type;
	typedef Result		result_type;
};


// arithmetic operations

template <class T>
struct plus : public binary_function<T, T, T>
{
	T operator()(const T& a, const T& b) const
	{ return a + b; }
};

template <class T>
struct minus : public binary_function<T, T, T>
{
	T operator()(const T& a, const T& b) const
	{ return a - b; }
};

template <class T>
struct multiplies : public binary_function<T, T, T>
{
	T operator()(const T& a, const T& b) const
	{ return a * b; }
};

template <class T>
struct divides : public binary_function<T, T, T>
{
	T operator()(const T& a, const T& b) const
	{ return a / b; }
};

template <class T>
struct modulus : public binary_function<T, T, T>
{
	T operator()(const T& a, const T& b) const
	{ return a % b; }
};

template <class T>
struct negate : public unary_function<T, T>
{
	T operator()(const T& a) const
	{ return -a; }
};


// comparison operations

template <class T>
struct equal_to : public binary_function<T, T, bool>
{
	bool operator()(const T& a, const T& b) const
	{ return a == b; }
};

template <class T>
struct not_equal_to : public binary_function<T, T, bool>
{
	bool operator()(const T& a, const T& b) const
	{ return a != b; }
};

template <class T>
struct greater : public binary_function<T, T, bool>
{
	bool operator()(const T& a, const T& b) const
	{ return a > b; }
};

template <class T>
struct less : public binary_function<T, T, bool>
{
	bool operator()(const T& a, const T& b) const
	{ return a < b; }
};

template <class T>
struct greater_equal : public binary_function<T, T, bool>
{
	bool operator()(const T& a, const T& b) const
	{ return a >= b; }
};

template <class T>
struct less_equal : public binary_function<T, T, bool>
{
	bool operator()(const T& a, const T& b) const
	{ return a <= b; }
};


// logical operations

template <class T>
struct logical_and : public binary_function<T, T, bool>
{
	bool operator()(const T& a, const T& b) const
		{ return a && b; }
};

template <class T>
struct logical_or : public binary_function<T, T, bool>
{
	bool operator()(const T& a, const T& b) const
		{ return a || b; }
};

template <class T>
struct logical_not : public unary_function<T, bool>
{
	bool operator()(const T& a) const
		{ return !a; }
};


// bitwise operations

template <class T>
struct bit_and : public binary_function<T, T, T>
{
	T operator()(const T& a, const T& b) const
	{ return a & b; }
};

template <class T>
struct bit_or : public binary_function<T, T, T>
{
	T operator()(const T& a, const T& b) const
	{ return a | b; }
};

template <class T>
struct bit_xor : public binary_function<T, T, T>
{
	T operator()(const T& a, const T& b) const
	{ return a ^ b; }
};



FC_NAMESPACE_END
